package com.cn.ant.modules.wechat.service;

import com.cn.ant.common.persistence.Page;
import com.cn.ant.common.service.BaseService;
import com.cn.ant.modules.wechat.dao.WeiXinNewListItemMapper;
import com.cn.ant.modules.wechat.entity.WeiXinNewListItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;
/**
 * 消息列表条目Service
 * @author AntDream
 * @version 2015-08-01
 */
@Component
@Transactional(readOnly = true)
public class WeiXinNewListItemService extends BaseService {

	@Autowired
	private WeiXinNewListItemMapper weiXinNewListItemMapper;
	
	public WeiXinNewListItem get(String id) {
		return weiXinNewListItemMapper.get(id);
	}
	
	public Page<WeiXinNewListItem> find(Page<WeiXinNewListItem> page, Map<String,Object> param) {
        param.put("startIdx", page.getFirstResult());
        param.put("pageSize", page.getPageSize());
        page.setList(weiXinNewListItemMapper.query(param));
        page.setCount(weiXinNewListItemMapper.queryCount(param));
        return page;
	}

    /**
     * 查询条目
     * @param typeId
     * @return
     */
	public List<WeiXinNewListItem> queryByTypeId(String typeId) {
        return weiXinNewListItemMapper.queryByTypeId(typeId);
    }

    @Transactional(readOnly = false)
	public void save(WeiXinNewListItem weiXinNewListItem) {
		weiXinNewListItemMapper.insert(weiXinNewListItem);
	}
	
	@Transactional(readOnly = false)
	public void update(WeiXinNewListItem weiXinNewListItem) {
		weiXinNewListItemMapper.update(weiXinNewListItem);
	}
	
	@Transactional(readOnly = false)
	public void delete(String id) {
		weiXinNewListItemMapper.delete(id);
	}
	
}
